﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RestApp.BusinessLogic.Code
{
    public class WorkTimeFormatter
    {
        public TimeSpan GetWorkTime(TimeSpan startTime, TimeSpan endTime)
        {
            TimeSpan twelve = new TimeSpan(24, 0, 0);
            TimeSpan ts = new TimeSpan();
            if(endTime.TotalMinutes < startTime.TotalMinutes)
            {
                ts = (twelve - startTime).Duration();
                ts += (endTime).Duration();
            }
            else
            {
                ts = endTime - startTime;
            }
            
            return ts.Duration();
        }
    }
}
